package leetcode.editor.cn.q1xx

class Q169 {
    fun majorityElement(nums: IntArray): Int {
        var count = 0
        var candidate = 0

        for (n in nums) {
            if (count == 0) {
                candidate = n
            }
            if (candidate==n) count++ else count--
        }
        return candidate
    }
}